cmake_minimum_required(VERSION 3.8)
project(agv_dispatch_comm)

if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 17)
  set(CMAKE_CXX_STANDARD_REQUIRED ON)
  set(CMAKE_CXX_EXTENSIONS OFF)
endif()

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(agv_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(agv_srvs REQUIRED)
find_package(shared_parameters REQUIRED)

find_package(OpenCV REQUIRED)
find_package(yaml-cpp REQUIRED)
find_package(Boost REQUIRED COMPONENTS system)

include_directories(
  include
  include/mqtt
  ${ament_INCLUDE_DIRS}
)

add_executable(${PROJECT_NAME}_node 
  src/dispatch_node.cpp 
  src/task_manager.cpp
)

target_link_libraries(${PROJECT_NAME}_node
  rclcpp::rclcpp
  std_msgs::std_msgs__rosidl_typesupport_cpp
  agv_msgs::agv_msgs__rosidl_typesupport_cpp
  agv_srvs::agv_srvs__rosidl_typesupport_cpp
  ${OpenCV_LIBRARIES}
  yaml-cpp
  ${PROJECT_SOURCE_DIR}/lib/libpaho-mqtt3a.a
  ${PROJECT_SOURCE_DIR}/lib/libpaho-mqtt3as.a
  ${PROJECT_SOURCE_DIR}/lib/libpaho-mqtt3c.a
  ${PROJECT_SOURCE_DIR}/lib/libpaho-mqtt3cs.a
  ${PROJECT_SOURCE_DIR}/lib/libpaho-mqttpp3.a
)

ament_target_dependencies(${PROJECT_NAME}_node
  rclcpp
  std_msgs
  agv_msgs
  agv_srvs
  nav_msgs
  sensor_msgs
  shared_parameters
)

install(TARGETS ${PROJECT_NAME}_node
  RUNTIME DESTINATION lib/${PROJECT_NAME}
)

install(DIRECTORY include/
  DESTINATION include/${PROJECT_NAME}
)

install(DIRECTORY config/
  DESTINATION share/${PROJECT_NAME}/config
)

install(DIRECTORY messages/
  DESTINATION share/${PROJECT_NAME}/messages
)

install(DIRECTORY schemas/
  DESTINATION share/${PROJECT_NAME}/schemas
)

#install(DIRECTORY lib/
#  DESTINATION lib
#)

ament_export_include_directories(include)
ament_export_libraries(${PROJECT_NAME}_node)
ament_export_dependencies(
  rclcpp
  std_msgs
  agv_msgs
  agv_srvs
  OpenCV
  yaml-cpp
)

ament_package()